package MultithreadingTest;

/**
 * 我的线
 *
 * @ClassName MyThread
 * @Description TODO
 * @Author ZhaoKai
 * @Date 2021-12-1710:05
 * @Version 1.0
 **/
public class MyThread extends Thread {
    public volatile boolean running = true;

    /**
     * 运行
     */
    public void run() {
        System.out.println("MyThread.run() start");

        if (running) {
            Thread hello = new HelloThread();
            hello.start();
            System.out.println("HelloThread start");
            try {
                hello.join();//等待hello线程结束
            } catch (InterruptedException e) {
                System.out.println("HelloThread interrupted!");
            }
            hello.interrupt();//请求中断hello线程
            System.out.println("hello.interrupt()");
            System.out.println("MyThread.run() end");
        }
    }

}
